<include file="Public:header" />

<script type="text/javascript" charset="utf-8" src="/Public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/Public/ueditor/ueditor.all.min.js"> </script>


<script type="text/javascript">
    //实例化编辑器
	UE.getEditor('context');
</script>

<div>
	<a href="/admin.php?m=Admin&c=Index&a=article&do=add">添加</a> &nbsp;&nbsp;搜索：<input name="search" id="searchInput"  />
</div>
<div class="article">
<if condition="$data['do'] eq 'add'">
<h2><if condition="$data['info']['id']">编辑<else />添加</if></h2>
 
<form method="post" id="form" action="/admin.php?m=Admin&c=Index&a=article&do=save">
<table width="100%" border="0">
  <tr>
    <td width="5%">标题</td>
    <td width="95%"><input name="title" type="text" id="title" value="{$data['info']['title']}" size="60" /></td>
  </tr>
  <tr>
    <td>url</td>
    <td><input name="url" type="text" id="url" value="{$data['info']['url']}" size="60" /></td>
  </tr>
  <tr>
    <td>分类</td>
    <td>
      <select name="cid" id="cid">
      <volist name="data['category']['list']" id="val">
        <option value="{$val['id']}"<if condition="$data['info']['cid'] eq $val['id']"> selected="selected"</if>>{$val['name']}</option>
      </volist>
      </select>   推荐  
      <select name="sort" id="sort">
        <option value="0" <if condition="$data['info']['sort'] eq 1"> selected="selected"</if>>--</option>
        <option value="1" <if condition="$data['info']['sort'] eq 1"> selected="selected"</if>>1</option>
      </select>    
    </td>
  </tr>
  <tr>
    <td>标签</td>
    <td><input name="tag" type="text" id="tag" value="{$data['info']['tag']}" size="60" /></td>
  </tr>
  <tr>
    <td>封面</td>
    <td>
		<div class="tupian" onclick="$('.uploadBtn').click();" style="cursor:pointer; width:100px; margin:5px; height:100px; background:#ccc;"><if condition="$data['info']['thumb']"><img src="{$data['info']['thumb150']}" style="max-width:100px; max-height:100px;" border=0 /><else />点击上传</if></div> 
    </td>
  </tr>
  <tr>
    <td valign="top">内容</td>
    <td><textarea name="context" id="context" style="width:90%; height:500px;">{$data['info']['context']}</textarea></td>
  </tr>
  <tr>
    <td height="99">&nbsp;</td>
    <td valign="top"><input type="submit" name="button" id="button" value="提交" style="padding:5px;" />
      <a href="javascript:" onclick="if(confirm('确定返回列表吗？内容可能会丢失')){ location.href='/admin.php?m=Admin&c=Index&a=article'} return">返回</a>
      <input name="id" type="hidden" id="id" value="{$data['info']['id']}" />
      <input type="hidden" name="thumb" value="{$data['info']['thumb']}" />    </td>
  </tr>
</table>
</form>
<form method="post" class="uploadImageForm" enctype="multipart/form-data" class="hide" target="iframe-form" action="/?c=Upload&a=upload">
<input type="file" name="upload" class="uploadBtn hide"  />
</form>
<else />
<h2>文章列表</h2>

<table width="100%" border="1" cellpadding="5" cellspacing="0">
  <tr>
    <th width="">标题</th>
    <th width="100px">分类</th>
    <th width="50px">推荐</th>
    <th width="180px">最后修改时间</th>
    <th width="100px">操作</th>
  </tr>
  <volist name="data['article']['list']" id="val">
  <tr>
    <td>{$val['title']}</td>
    <td>{$val['cid']}</td>
    <td>{$val['sort']}</td>
    <td title="发表时间：{$val['createtime']}">{$val['updatetime']}</td>
    <td><a href="/admin.php?m=Admin&c=Index&a=article&do=add&id={$val['id']}">编辑</a></td>
  </tr>
  </volist>
</table>
<p><if condition="$_GET['p'] gt 1"><a href="/admin.php?m=Admin&c=Index&a=article">首页</a>&nbsp;&nbsp;<a href="/admin.php?m=Admin&c=Index&a=article&p={$data['article']['next_page']-1}">上一页</a>&nbsp;&nbsp;<else /></if> <if condition="$data['article']['next_page']"><a href="/admin.php?m=Admin&c=Index&a=article&p={$data['article']['next_page']}">下一页</a>&nbsp;&nbsp;</if></p>
</if>
</div>
<script>
$(document).ready(function(){	
	$('.uploadBtn').on('change',function(){
		var editForm = $('.uploadImageForm');
		//$.jBox.tip('Loading...','loading');
		//editForm.find('.tupian').html('上传中...');
		$('.uploadImageForm').submit();
	});
});
//上传成功回调
function uploadCallBack(domain,path){
	var editForm = $('#form');
	editForm.find('[name=thumb]').val(path);
	editForm.find('.tupian').html('<img src="'+domain+path+'" style="max-width:100px; max-height:100px;" border=0 />');
	$.jBox.tip('上传成功','success');
}
</script>
<iframe id="iframe-form" name="iframe-form" src="" class="hide" ></iframe>
<include file="Public:footer" />
